package com.yp.loading.widget;

import android.annotation.SuppressLint;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.yp.loading.R;
import com.yp.loading.base.BaseDialog;

/**
 * 作者：刘江飞
 * 时间：2020/7/10
 * 邮箱：642371742@qq.com
 * 描述：进度Dialog
 */
public class ProgressDialog extends BaseDialog {
    private TextView tvHint;
    private ProgressBar pbProgress;
    private TextView tvProgress;


    @Override
    public boolean isCancelable() {
        return false;
    }

    @Override
    protected boolean isCancelOutside() {
        return false;
    }

    @Override
    protected int setLayoutId() {
        return R.layout.dialog_progress;
    }

    @Override
    protected void initView() {
        super.initView();
        tvHint = mRootView.findViewById(R.id.tv_hint);
        pbProgress = mRootView.findViewById(R.id.pb_progress);
        tvProgress = mRootView.findViewById(R.id.tv_progress);
    }

    @Override
    protected void initData() {
        super.initData();
    }

    public void setCurrentHint(String hint) {
        if (tvHint == null) {
            return;
        }
        tvHint.setText(hint);
    }


    @SuppressLint("SetTextI18n")
    public void setCurrentProgress(int progress) {
        if (pbProgress == null) {
            return;
        }
        pbProgress.setProgress(progress);

        if (tvProgress == null) {
            return;
        }
        tvProgress.setText(progress + "%");
    }

    @Override
    public void onClick(View v) {

    }
}
